/***********************************************************************
 * Module:  StandardNetworkLayer.java
 * Author:  Mladen
 * Purpose: Defines the Class StandardNetworkLayer
 ***********************************************************************/

package raf.neural;

import raf.core.NodeInterface;
import java.util.Vector;
import java.util.*;

public class StandardNetworkLayer extends raf.core.AbstractNetworkLayer {
	
	private boolean outputLayer = false;
	private int neuronsCount;
	private int inputsCount;
	private Double[] output;
	
	public StandardNetworkLayer(int _neurons, int _inputsCount, boolean _output) {
		outputLayer = _output;
		neuronsCount = _neurons;
		inputsCount = _inputsCount;
		output = new Double[neuronsCount];
	}

	public void propagateLayer(Double[] _inputs) {
		int i=0;
		for (NodeInterface node : nodeInterface) {
			node.calculateOutput(_inputs);
			output[i] = node.getOutput();
			++i;
		}
	}

	public void propagateError() {
	}

	public void initialize() {
		nodeInterface = new Vector<NodeInterface>();
		NodeInterface node;
		for(int i=0;i<neuronsCount;i++) {
			node = new NeuralNetworkNode(inputsCount);
			node.initialize();
			nodeInterface.add(node);
		}
	}
	
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		for (NodeInterface node : nodeInterface) {
			buffer.append(node);
		}
		return buffer.toString();
	}
}